(function(env) {
	//编译
	const {
		scriptCompile
	} = require('./stringCompile.js');
	//运行环境的一些适配
	const {
		getUUID,
		findByIndex,
		findStrAndSplit
	} = require('./env.js');
	const {
		registerOperator,
	} = require('./operator.js');
	//计算
	const {
		calculate
	} = require('./calculate.js');
	//到全局变量
	env.myeval = {
		registerOperator,
		run(data, vars) {
			if (vars == null) {
				vars = [env];
			}
			let codes = (typeof data) == "string" ? this.compile(data) : data;
			return calculate(codes, vars);
		},
		compile(str) {
			if (str && str.length > 0) {
				return scriptCompile(str);
			}
			throw "你传个空字符串进来干啥...";
		}
	};
	//符号:*
	registerOperator({
		operator: "*",
		level: 10,
		fun: (a, b) => a * b
	});
	//符号:%
	registerOperator({
		operator: "%",
		level: 10,
		fun: (a, b) => a % b
	});
	//符号:/
	registerOperator({
		operator: "/",
		level: 10,
		fun: (a, b) => a / b
	});
	//符号:+
	registerOperator({
		operator: "+",
		level: 9,
		fun: (a, b) => a + b
	});
	//符号:-
	registerOperator({
		operator: "-",
		level: 9,
		fun: (a, b) => a - b
	});
	//符号:>=
	registerOperator({
		operator: ">=",
		level: 5,
		fun: (a, b) => a >= b
	});
	//符号:<=
	registerOperator({
		operator: "<=",
		level: 5,
		fun: (a, b) => a <= b
	});
	//符号:>
	registerOperator({
		operator: ">",
		level: 4,
		fun: (a, b) => a > b
	});
	//符号:<
	registerOperator({
		operator: "<",
		level: 4,
		fun: (a, b) => a < b
	});
	//符号:==
	registerOperator({
		operator: "==",
		level: 3,
		fun: (a, b) => a == b
	});
	//符号:!=
	registerOperator({
		operator: "!=",
		level: 3,
		fun: (a, b) => a != b
	});
	//符号:&&
	registerOperator({
		operator: "&&",
		level: 2,
		fun: (a, b) => a && b
	});
	//符号:||
	registerOperator({
		operator: "||",
		level: 1,
		fun: (a, b) => a || b
	});
})(window);
